package cn.enjoyedu.udp.unicastLearn;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioDatagramChannel;




public class UdpAnswerSide {
   public static final int ANSWER_PORT=8080;
    public final static String ANSWER="故事来了：";
    public void run(int port) throws InterruptedException {
        EventLoopGroup group=new NioEventLoopGroup();
        try {
            Bootstrap b=new Bootstrap();
            b.group(group).channel(NioDatagramChannel.class)
                    .handler(new AnswerHandler());
            ChannelFuture f = b.bind(port).sync();
            System.out.println("应答服务器已启动。。。。");
            f.channel().closeFuture().sync();
        }finally {
            group.shutdownGracefully();
        }

    }
    public static void main(String[] args) throws InterruptedException {
        new UdpAnswerSide().run(ANSWER_PORT);

    }


}
